package com.coursehub.exercise.entity;

import jakarta.persistence.*;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

/**
 * 练习题目关联实体
 */
@Getter
@Setter
@NoArgsConstructor
@Entity
@Table(name = "exercise_question")
public class ExerciseQuestion {
    
    @EmbeddedId
    private ExerciseQuestionId id;
    
    @MapsId("exerciseId")
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @JoinColumn(name = "exercise_id", nullable = false, insertable = false, updatable = false)
    private Exercise exercise;
    
    @MapsId("questionId")
    @ManyToOne(fetch = FetchType.LAZY, optional = false)
    @JoinColumn(name = "question_id", nullable = false, insertable = false, updatable = false)
    private Question question;
    
    public ExerciseQuestion(ExerciseQuestionId id, Exercise exercise, Question question) {
        this.id = id;
        this.exercise = exercise;
        this.question = question;
    }
}